#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
const int MAXN = 1e5 + 5;
const int MAXL = 1e6 + 5;
int n, m;
ld L, V;
ld d[MAXN], v[MAXN], a[MAXN];
ld p[MAXN];
int presum[MAXL];
struct segment{
    ld l, r;
    int type;
}segs[MAXN << 1];
bool cmp(segment a, segment b){
    if(abs(a.r - b.r) < 1e-15){
        if(abs(a.l - b.l) < 1e-15)return a.type > b.type;
        return a.l > b.l + 1e-15;
    }
    return a.r + 1e-15 < b.r;
}
int cnt;
int main(){
    freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int T; cin >> T;
    while(T--){
        for(int i = 1; i <= 1e6; i++)presum[i] = 0;
        cnt = 0;
        cin >> n >> m >> L >> V;
        for(int i = 1; i <= n; i++)cin >> d[i] >> v[i] >> a[i];
        for(int i = 1; i <= m; i++)cin >> p[i], presum[(int)p[i]] = 1, segs[++cnt] = {p[i], p[i], 1};
        for(int i = 1; i <= 1e6; i++)presum[i] += presum[i - 1];
        for(int i = 1; i <= n; i++){
            if(a[i] == 0){
                if(v[i] <= V)continue;
                segs[++cnt] = {d[i], L, 0};
            }
            else if(a[i] < 0){
                if(v[i]  <= V)continue;
                segs[++cnt] = {d[i], d[i] + min(L, (V * V - v[i] * v[i]) / ((ld)2.0 * a[i])), 0};
            }
            else{
                //if(v[i] == 1 && a[i] == 4){
                //    cout << d[i] + max((ld)0, (V * V - v[i] * v[i] / ((ld)2.0 * a[i]))) << L;
                //}
                if(v[i] * v[i] + 2 * a[i] * (L - d[i]) + 1e-15 <= V * V) continue;
                segs[++cnt] = {d[i] + max((ld)0, ((V * V - v[i] * v[i]) / ((ld)2.0 * a[i]))), L, 0};
            }
        }//all segs added

        sort(segs + 1, segs + cnt + 1, cmp);

        //for(int i = 1; i <= cnt; i++)
        //    cout << segs[i].l << ' ' << segs[i].r << '\n';

        ld lastp = -1e9, nowp = -1e9;
        int carcnt = 0, pcnt = 0;
        for(int i = 1; i <= cnt; i++){
            if(segs[i].type == 1)lastp = segs[i].l;
            else{
                if(segs[i].l <= nowp){
                    carcnt++;
                    continue;
                }
                else if(segs[i].l <= lastp){
                    nowp = lastp;
                    carcnt++;
                    pcnt++;
                    continue;
                }
                else continue;
            }
        }
        cout << carcnt << ' ' << m - pcnt << '\n';
    }
}